package jwj8508.swing.jdbc;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

//새 성적 : J26_SungJukNewData 이름, 국어, 영어, 수학을 입력받음

public class J26_SungJukNewData extends JDialog {
	
	private JTextField name;
	private JTextField kor;
	private JTextField eng;
	private JTextField mat;
	private JTextField name_1;

	public J26_SungJukNewData(JFrame p) {
		super(p);
		setTitle("새 성적");
		setModalityType(ModalityType.DOCUMENT_MODAL);
		setSize(640, 480);
		setLocationRelativeTo(null);		
		
		getContentPane().setLayout(new BorderLayout());
		{
			JPanel buttonPane = new JPanel();
			buttonPane.setPreferredSize(new Dimension(10, 50));
			buttonPane.setLayout(new FlowLayout(FlowLayout.CENTER));
			getContentPane().add(buttonPane, BorderLayout.SOUTH);
			{
				JButton okButton = new JButton("확인");
				okButton.addActionListener(new ActionListener() {
					@Override
					public void actionPerformed(ActionEvent e) {
						
						if (name.getText().equals("") || kor.getText().equals("") || eng.getText().equals("") || mat.getText().equals("")) {
							JOptionPane.showMessageDialog(null, "제대로", "!!", JOptionPane.ERROR_MESSAGE);
							return;
						}

						/*EX01_SungJukVO sj = new EX01_SungJukVO();
						sj.setName(name.getText());
						sj.setKor(Integer.parseInt(kor.getText()));
						sj.setEng(Integer.parseInt(eng.getText()));
						sj.setMat(Integer.parseInt(mat.getText()));
						String msg = sj.getName()+ "/"  + sj.getKor() + "/" + sj.getEng() + "/" + sj.getMat(); */
					}
				});

				okButton.setActionCommand("OK");
				buttonPane.add(okButton);
				getRootPane().setDefaultButton(okButton);
			}
			{
				JButton cancelButton = new JButton("취소");
				cancelButton.setActionCommand("Cancel");
				buttonPane.add(cancelButton);
			}
		}
		{
			JPanel panel = new JPanel();
			getContentPane().add(panel, BorderLayout.CENTER);
			panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
			{
				JPanel panel_1 = new JPanel();
				panel.add(panel_1);
				GridBagLayout gridBagLayout = new GridBagLayout();
				gridBagLayout.columnWidths = new int[] { 65, 0, 0, 30, 0, 0 };
				gridBagLayout.rowHeights = new int[] { 50, 0, 0, 30, 0, 0, 30,
						0, 30, 0, 30, 0, 30, 0, 0 };
				gridBagLayout.columnWeights = new double[] { 0.0, 0.0, 0.0,
						0.0, 0.0, Double.MIN_VALUE };
				gridBagLayout.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0,
						0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
						Double.MIN_VALUE };
				panel_1.setLayout(gridBagLayout);

				JLabel titlelbl = new JLabel("이름과 성적을 입력하세요");
				titlelbl.setFont(new Font("맑은 고딕", Font.BOLD, 34));
				GridBagConstraints gbc_titlelbl = new GridBagConstraints();
				gbc_titlelbl.insets = new Insets(0, 0, 5, 0);
				gbc_titlelbl.gridx = 4;
				gbc_titlelbl.gridy = 2;
				panel_1.add(titlelbl, gbc_titlelbl);

				JLabel namelbl = new JLabel("이    름");
				namelbl.setFont(new Font("맑은 고딕", Font.BOLD, 16));
				GridBagConstraints gbc_namelbl = new GridBagConstraints();
				gbc_namelbl.insets = new Insets(0, 0, 5, 5);
				gbc_namelbl.gridx = 2;
				gbc_namelbl.gridy = 5;
				panel_1.add(namelbl, gbc_namelbl);

				name = new JTextField();
				name.setFont(new Font("맑은 고딕", Font.BOLD, 16));
				GridBagConstraints gbc_name = new GridBagConstraints();
				gbc_name.insets = new Insets(0, 0, 5, 0);
				gbc_name.fill = GridBagConstraints.HORIZONTAL;
				gbc_name.gridx = 4;
				gbc_name.gridy = 5;
				panel_1.add(name, gbc_name);
				name.setColumns(10);
				
				name_1 = new JTextField();
				GridBagConstraints gbc_name_1 = new GridBagConstraints();
				gbc_name_1.insets = new Insets(0, 0, 5, 0);
				gbc_name_1.fill = GridBagConstraints.HORIZONTAL;
				gbc_name_1.gridx = 4;
				gbc_name_1.gridy = 5;
				panel_1.add(name_1, gbc_name_1);
				name_1.setColumns(10);

				JLabel korlbl = new JLabel("국    어");
				korlbl.setFont(new Font("맑은 고딕", Font.BOLD, 16));
				GridBagConstraints gbc_korlbl = new GridBagConstraints();
				gbc_korlbl.insets = new Insets(0, 0, 5, 5);
				gbc_korlbl.gridx = 2;
				gbc_korlbl.gridy = 7;
				panel_1.add(korlbl, gbc_korlbl);

				kor = new JTextField();
				kor.setFont(new Font("맑은 고딕", Font.BOLD, 16));
				GridBagConstraints gbc_kor = new GridBagConstraints();
				gbc_kor.insets = new Insets(0, 0, 5, 0);
				gbc_kor.fill = GridBagConstraints.HORIZONTAL;
				gbc_kor.gridx = 4;
				gbc_kor.gridy = 7;
				panel_1.add(kor, gbc_kor);
				kor.setColumns(10);

				JLabel englbl = new JLabel("영    어");
				englbl.setFont(new Font("맑은 고딕", Font.BOLD, 16));
				GridBagConstraints gbc_englbl = new GridBagConstraints();
				gbc_englbl.insets = new Insets(0, 0, 5, 5);
				gbc_englbl.gridx = 2;
				gbc_englbl.gridy = 9;
				panel_1.add(englbl, gbc_englbl);

				eng = new JTextField();
				eng.setFont(new Font("맑은 고딕", Font.BOLD, 16));
				GridBagConstraints gbc_eng = new GridBagConstraints();
				gbc_eng.insets = new Insets(0, 0, 5, 0);
				gbc_eng.fill = GridBagConstraints.HORIZONTAL;
				gbc_eng.gridx = 4;
				gbc_eng.gridy = 9;
				panel_1.add(eng, gbc_eng);
				eng.setColumns(10);

				JLabel matlbl = new JLabel("수    학");
				matlbl.setFont(new Font("맑은 고딕", Font.BOLD, 16));
				GridBagConstraints gbc_matlbl = new GridBagConstraints();
				gbc_matlbl.insets = new Insets(0, 0, 5, 5);
				gbc_matlbl.gridx = 2;
				gbc_matlbl.gridy = 11;
				panel_1.add(matlbl, gbc_matlbl);

				mat = new JTextField();
				mat.setFont(new Font("맑은 고딕", Font.BOLD, 16));
				GridBagConstraints gbc_mat = new GridBagConstraints();
				gbc_mat.insets = new Insets(0, 0, 5, 0);
				gbc_mat.fill = GridBagConstraints.HORIZONTAL;
				gbc_mat.gridx = 4;
				gbc_mat.gridy = 11;
				panel_1.add(mat, gbc_mat);
				mat.setColumns(10);
			}

		}

		setVisible(true);
	}
}
